#!/bin/sh

./StopCodeServer

g_rootPath=$(pwd)

codeServerBin=${g_rootPath}/code-server/bin/code-server
userDir=${g_rootPath}/user
extensionsDir=${g_rootPath}/extensions
logDir=${g_rootPath}/log
configFile=${g_rootPath}/config/config.yaml
logFile=${logDir}/`date +%Y%m%d%H%M%S`.log

titleText="Welcome to david code server"

if [ ! -d "${userDir}" ];then
    mkdir -p "${userDir}"
fi

if [ ! -d "${extensionsDir}" ];then
    mkdir -p "${extensionsDir}"
fi

if [ ! -d "${logDir}" ];then
    mkdir -p "${logDir}"
fi

${codeServerBin} --user-data-dir ${userDir} --extensions-dir ${extensionsDir} --config ${configFile} ${certCfg} -w ${titleText} --disable-telemetry --disable-update-check > ${logFile} 2>&1 &

echo "log storage directory file: ${logFile}"
